package com.ronri.ams.sample;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;

import com.cz.nongyetongv5.R;
import com.ronri.PhotoGraph.JCameraView;



/**
 * 文件：ams.java
 * 包名：com.ronri.ams.sample;
 * 说明：
 * 作者：MS During
 * 日期：2017/6/16
 * 历史：
 */
public class activity_control_photograph
        extends abstract_activity {

    private JCameraView mJCameraView;
    private String mszPath = "";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置无标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        //设置全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        Bundle bundle = getIntent().getExtras();

        if (bundle != null)
        {
            mszPath = bundle.getString("photoFilePath");
        }

        setContentView(R.layout.activity_camera);
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);

        //////////////////////////////////////////////////////////////////
        mJCameraView = (JCameraView) findViewById(R.id.cameraview);
        mJCameraView.initCamera(this, mszPath);
        mJCameraView.setCameraViewListener(new JCameraView.CameraViewListener() {
            @Override
            public void quit() {
                activity_control_photograph.this.finish();
            }

            @Override
            public void captureSuccess(Bitmap bitmap) {
                setResult(RESULT_OK);
                activity_control_photograph.this.finish();
            }

            @Override
            public void recordSuccess(String url) {
                Toast.makeText(activity_control_photograph.this,"获取到视频路径:"+url, Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        mJCameraView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mJCameraView.onPause();
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    public void toFinish() {
        mJCameraView.OnDestory();
        mJCameraView.destroyDrawingCache();
        super.toFinish();
    }
}
